/*
 * @ : Copyright (c) 2021 Phytium Information Technology, Inc. 
 *  
 * SPDX-License-Identifier: Apache-2.0.
 * 
 * @Date: 2021-08-06 08:05:34
 * @LastEditTime: 2021-08-16 15:22:28
 * @Description:  This files is for 
 * 
 * @Modify History: 
 *  Ver   Who        Date         Changes
 * ----- ------     --------    --------------------------------------
 */
#include "kernel.h"
#include "ft_types.h"
#include "ft_io.h"
#include "aarch64.h"
#include <stdio.h>

extern void OutByte(s8 byte);

u32 raw_read_cpacr_el1(void)
{
    u32 cpacr_el1;

    __asm__ __volatile__("mrs %0, cpacr_el1\n\t"
                         : "=r"(cpacr_el1)
                         :
                         : "memory");

    return cpacr_el1;
}

void reg_check(void)
{
    printf("cpacr_el1 %x \r\n", raw_read_cpacr_el1());
    while (1)
    {
        /* code */
    }
}

void hcr_el2_printf(void)
{
    printf("hcr_el2 %lx \r\n", get_hcr_el2());
    while (1)
    {
        /* code */
    }
}

void print_xregs(u64 x0, u64 x1, u64 x2)
{
    printf("x0 %lx \r\n", x0);
    printf("x1 %lx \r\n", x1);
    printf("x2 %lx \r\n", x2);
}

void asm_pos_print(void)
{
    OutByte('2');
    OutByte('3');
    OutByte('3');
    OutByte('\n');
}

void asnyc_error_print(void)
{
    OutByte('a');
    OutByte('s');
    OutByte('s');
    OutByte('e');
    OutByte('\n');

    while (1)
    {
        /* code */
    }
}

void check_error_print(void)
{
    OutByte('c');
    OutByte('h');
    OutByte('e');
    OutByte('c');
    OutByte('k');
    OutByte('\n');

    while (1)
    {
        /* code */
    }
}
